import { useState } from "react";
import { Button, Text, View } from "react-native";
interface ChildProps{
  num:number;
  a:React.Dispatch<React.SetStateAction<number>>;
}
export default function App() {
   const [num,setNum]=useState(100);
  return (
    // 父组件
    <View>
      <Text>==========</Text>
      <Text>父组件数据：{num}</Text>
      <Child num={num} a={setNum}/>
      <Text>===============</Text>
    </View>
  )
  };

  function Child({num,a}:ChildProps){
    const changeNum=()=>{
      a(num+1);
    }
    const reduceNum=()=>{
      a(num-1);
    }
    return(
      <View>
        <Text>子组件数据：{num}</Text>
          <Button title="增加计数" onPress={changeNum}/>
          <View style={{marginTop:10}}>
          <Button title="减少计数" onPress={reduceNum}/>
        </View>
      
      </View>
    )
  }
